import Vue from 'vue'
import VueRouter from 'vue-router'
// import Login from '../views/LoginView.vue'
import User from '../views/admin/ShowUsers.vue'
import Expert from '@/views/admin/ShowExpert.vue'
// import First from '../views/admin/First.vue'
import Units from '../views/admin/ShowUnits.vue'
import showproject from '../views/admin/ShowProjectCategorys.vue'
import Second from '../views/expert/Second.vue'
import Viewexpertinfo from '../views/expert/Viewexpertinfo.vue'
import Reworkpassword from '../views/expert/Reworkpassword.vue'
import ShowprojectCategorys from '../views/expert/ShowprojectCategorys.vue'
import viewunitinfo from '../views/unit/Viewunitinfo.vue'
import password from '../views/unit/password.vue'
import UnitshowprojectCategorys from '../views/unit/UnitshowprojectCategorys.vue'
import simpleSearch from '../views/unit/SimpleSearch.vue'

Vue.use(VueRouter)

const RouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
  return RouterPush.call(this, to).catch(err => err)
}

const routes = [
  {
    path: '/',
    redirect:'/login'
  },
  {
    path: '/login',
    component: () => import('../views/LoginView.vue'),
  },

  // admin路由
  {
    path: '/admin/',
    component: () => import('../views/admin/First.vue'),
    redirect:'/admin/showusers',
    children:[
      {
        path: 'showusers',
        component: User,
      },
      {
        path: 'showexpert',
        component: Expert,
      },
      {
        path: 'showunit',
        component: Units,
      },
      {
        path: 'showproject',
        component: showproject,
      },
    ]
  }, 
  
  



  // expert路由
  {
    path: '/expert/',
    component: Second,
    redirect:'/expert/viewexpertinfo',
    children:[
      {
        path: 'viewexpertinfo',
        component: Viewexpertinfo
      },
      {
        path: 'reworkpassword',
        component: Reworkpassword
      },
      {
        path: 'showprojectCategorys',
        component: ShowprojectCategorys
      }
    
    ]
  },
  // redirect: '/expert/viewexpertinfo',

  

  // unit路由
  {
    path: '/unit/',
    component: () => import('../views/unit/Third.vue'),
    redirect:'/unit/viewunitinfo',
    children:[
      {
        path: 'viewunitinfo',
        component: viewunitinfo
      },
      {
        path: 'password',
        component: password
      },
      {
        path: 'UnitshowprojectCategorys',
        component: UnitshowprojectCategorys
      },
      {
        path: 'simpleSearch',
        component: simpleSearch
      }
    ]
  },
      
  
     

]

const router = new VueRouter({
    routes
  })

export default router
